﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MenuConfig.aspx.cs" Inherits="ZLCMS.Web.SystemManage.Basics.MenuConfig" %>



<div class="pageContent">   
   	<div class="panelBar">
		<ul class="toolBar">           
            <li><a class="icon" href="javascript:void(0)" onclick="navTab.reload();" title="刷新目录"><span>刷新目录</span></a></li>
 		</ul>
	</div>

    <div class="unitBox" style="float:left; display:block; overflow:auto; width:358px;">
<div class="pageHeader" style="border:1px #B8D0D6 solid">
	<div class="searchBar">
		<table class="searchContent" width="100%">
			<tr>
				<td width="300px"><h3>菜单目录</h3>
				</td>
			</tr>
		</table>
	</div>
</div>
		
        
<div class="pageContent" style="border:1px #B8D0D6 solid;"  layoutH="70">

<div class="pageFormContent" layoutH="128">
<ul class="ztree" id="adminmenu_tree" setting='
{
	view: {
		addHoverDom: addHoverDom,
		removeHoverDom: removeHoverDom,
		selectedMulti: false
	},
    data: {
		key: {
			name: "Title"
		},
		simpleData: {
			enable: true,
			idKey: "Id",
			pIdKey: "Preid"
		},
		keep: {
			parent: false,
			leaf: false
		}
	},
	async: {
		enable: true,
		type: "post",
		url: "/SystemManage/Basics/Menu/MenuConfigInterface.aspx?opt=load_data",
        otherParam: ["temp", new Date().valueOf()]
	},
    edit: {
		enable: true,
		editNameSelectAll: false,
		showRemoveBtn: true,
		showRenameBtn: true,
		removeTitle: "删除",
		renameTitle: "修改"
	},
	callback: {
		beforeDrag: function (treeId, treeNodes) {
			return false;
		},
        onAsyncSuccess:function(event, treeId, treeNode, msg){
            var ztree = $.fn.zTree.getZTreeObj(treeId);
            var roots = ztree.getNodes();
            if(roots.length>0){
                ztree.expandNode(roots[0],true);
            }
        },
        beforeRename: function(treeId, treeNode, newName, isCancel){
            
            $.get("/SystemManage/Basics/Menu/MenuConfigInterface.aspx", {opt:"update", Title:newName, Preid:treeNode.ParentId, Id:treeNode.Id, temp:new Date().valueOf()}, function(data){
                var obj=$.parseJSON(data);
                treeNode.ItemText = obj.ItemText;
                $.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
                alertMsg.correct("操作成功");
            });
            return true;
        },
        beforeRemove:function(treeId, treeNode){
            alertMsg.confirm("请确认删除当前菜单项", {
                okCall: function() {
                    $.get("/SystemManage/Basics/Menu/MenuConfigInterface.aspx", {opt:"remove", Id:treeNode.Id, temp:new Date().valueOf()}, function(data){
                        $.fn.zTree.getZTreeObj(treeId).removeChildNodes(treeNode);
                        $.fn.zTree.getZTreeObj(treeId).removeNode(treeNode);
                        alertMsg.correct("操作成功");
                    }); 
                }
            });
            return false;
        },
        onClick:function(event, treeId, treeNode, clickFlag){
            $("#Id",navTab.getCurrentPanel()).val(treeNode.Id);
            $("#ip_preid",navTab.getCurrentPanel()).val(treeNode.Preid);
            $("#ip_url",navTab.getCurrentPanel()).val(treeNode.Menuurl);
            $("#Sort",navTab.getCurrentPanel()).val(treeNode.Menuorder);
            $("#ip_p1",navTab.getCurrentPanel()).val(treeNode.Param1);
            $("#ip_p2",navTab.getCurrentPanel()).val(treeNode.Param2);
            $("#ip_p3",navTab.getCurrentPanel()).val(treeNode.Param3);
            $("#ip_title",navTab.getCurrentPanel()).val(treeNode.Title);
            _currentNode = treeNode;
        }
	}
}
'/>
</div>
<div class="formBar">
	    <ul>
			<li>
	        <div class="buttonActive"><div class="buttonContent"><button onclick="addItem('adminmenu_tree')" type="button">添加目录</button></div></div>
            </li>
		</ul>
</div>
<script type="text/javascript">
    var _currentNode = {};
    function addItem(treeId, parentNode) {
        var pid = 0;
        if (parentNode) {
            pid = parentNode.Id;
        }
        $.get("/SystemManage/Basics/Menu/MenuConfigInterface.aspx", { opt: "add", Title: "新的菜单", Preid: pid, temp: new Date().valueOf() }, function (data) {
            var zTree = $.fn.zTree.getZTreeObj(treeId);
            if (parentNode) {
                zTree.addNodes(parentNode, $.parseJSON(data));
            } else {
                zTree.addNodes(null, $.parseJSON(data));
            }
        });
    }

    function addHoverDom(treeId, treeNode) {
        var sObj = $("#" + treeNode.tId + "_span");
        if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0) return;
        var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
				+ "' title='增加子目录' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        var btn = $("#addBtn_" + treeNode.tId);
        if (btn) btn.bind("click", function () {
            addItem(treeId, treeNode);
            return false;
        });
    };
    function removeHoverDom(treeId, treeNode) {
        $("#addBtn_" + treeNode.tId).unbind().remove();
    };

</script>

 
</div>
	</div>
	










<div class="unitBox" style="margin-left:360px;">
	<div class="pageHeader" style="border:1px #B8D0D6 solid">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td><h3>详细设置</h3>
				</td>

			</tr>
		</table>
	</div>
</div>	


<div class="pageContent" style="border:1px #B8D0D6 solid;"  layoutH="70">

<div class="pageFormContent" layoutH="128">

        <dl class="nowrap">
            <dt>编号：</dt>
            <dd><input id="Id" type="text" disabled="disabled" /></dd>
        </dl>
        <dl class="nowrap">
            <dt>标题：</dt>
            <dd><input id="ip_title" type="text"/></dd>
        </dl>
        <dl class="nowrap">
            <dt>上级编号：</dt>
            <dd><input id="ip_preid" type="text"/>&nbsp;请输入数字</dd>
        </dl>
        <dl class="nowrap">
            <dt>目标URL：</dt>
            <dd><input id="ip_url" type="text" style="width:400px" /></dd>
        </dl>
        <dl class="nowrap">
            <dt>目录排序：</dt>
            <dd><input id="Sort" type="text" class="digits" />&nbsp;请输入数字</dd>
        </dl>
        <dl class="nowrap">
            <dt>参数1：</dt>
            <dd><input id="ip_p1" type="text" /></dd>
        </dl>
        <dl class="nowrap">
            <dt>参数2：</dt>
            <dd><input id="ip_p2" type="text" /></dd>
        </dl>
        <dl class="nowrap">
            <dt>参数3：</dt>
            <dd><input id="ip_p3" type="text" /></dd>
        </dl>
</div>
<div class="formBar">
	    <ul>
			<li>
	        <div class="buttonActive"><div class="buttonContent"><button onclick="submitMenuItem();" type="button">提交</button></div></div>
            </li>
		</ul>
</div>
</div>
<script type="text/javascript">

    function submitMenuItem() {
        //alertMsg.confirm("请确认提交", {
        //   okCall: function () {


        $.get("/SystemManage/Basics/Menu/MenuConfigInterface.aspx", { opt: "update_ex", 
            Id: $("#Id", navTab.getCurrentPanel()).val(),
            Sort: $("#Sort", navTab.getCurrentPanel()).val(),
            Url: $("#ip_url", navTab.getCurrentPanel()).val(),
            Preid: $("#ip_preid", navTab.getCurrentPanel()).val(),
            Param1: $("#ip_p1", navTab.getCurrentPanel()).val(),
            Param2: $("#ip_p2", navTab.getCurrentPanel()).val(),
            Param3: $("#ip_p3", navTab.getCurrentPanel()).val(),
            Title: $("#ip_title", navTab.getCurrentPanel()).val(),
            temp: new Date().valueOf()
        }, function () {
            alertMsg.correct("操作成功");
            _currentNode.Id = $("#Id", navTab.getCurrentPanel()).val();
            _currentNode.Menuorder = $("#Sort", navTab.getCurrentPanel()).val();
            _currentNode.Menuurl = $("#ip_url", navTab.getCurrentPanel()).val();
            _currentNode.Preid = $("#ip_preid", navTab.getCurrentPanel()).val();
            _currentNode.Param1 = $("#ip_p1", navTab.getCurrentPanel()).val();
            _currentNode.Param2 = $("#ip_p2", navTab.getCurrentPanel()).val();
            _currentNode.Param3 = $("#ip_p3", navTab.getCurrentPanel()).val();
            _currentNode.Title = $("#ip_title", navTab.getCurrentPanel()).val();
        });
        // }
        //});
    }

</script>
</div>
	
</div>